package obj;

import org.newdawn.slick.Animation;
import org.newdawn.slick.SlickException;

import play.Things;

/**
 * Jumping enemy class.
 * @author VincentLy
 */
public class JumpingEnemy extends MovingEnemy{
	
	public JumpingEnemy(float x,float y,int d,Animation a) throws SlickException{
		super(x,y,d,a);
	}
	
	/**
	 * Does everything a MovingEnemy does while constantly jumping whenever possible.
	 * @author VincentLy
	 */
	public void update(){
		super.update();
		if(Math.abs(x()-Things.player.x())<200)
			setXVel(-15*Integer.signum((int) (x()-Things.player.x())));				
		if(platform()!=null){
			if(Math.random()>.5){
				setYVel(60);
				move(x(),y()-1);
				setPlatform(null);
			}	
		}
	}
}